package Package.SpecialActionFlow.TheObjectDeserializesTheStream;

import Package.SpecialActionFlow.ObjectSerializationStream.Student;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

public class TheDbjectDeserializesTheStream {
    public static  void TheDbjectDeserializesTheStream() throws IOException, ClassNotFoundException {
//        对象反序列化流： ObjectInputStream
//ObjectInputStream反序列化先前使用ObjectOutputStream编写的原始数据和对象
//方法名 说明
//ObjectInputStream(InputStream in) 创建从指定的InputStream读取的ObjectInputStream
//构造方法
//方法名 说明
//Object readObject() 从ObjectInputStream读取一个对象
        ObjectInputStream OIS=new ObjectInputStream(new FileInputStream("D:\\insert\\oos.java"));
        Object obj=OIS.readObject();
        Student s=(Student) obj;
        System.out.println(s.getName()+","+s.getAge());
        OIS.close();

    }
}
